<template>
  <div class="container1">
    <div class="content">
      <div class="left">
        <fire-alarm-display :displayText="displayText" />
      </div>
      <div class="right">
        <div class="item" style="flex: 5">
          <fire-alarm-indicators @indicator-change="handleIndicatorChange" />
        </div>
        <div class="item" style="flex: 4">
          <fire-alarm-buttons
            :buttons="buttons"
            @button-click="handleButtonClick"
          />
        </div>
      </div>
    </div>
    <div class="title-box">火灾报警控制器</div>
  </div>
</template>

<script>
import FireAlarmDisplay from "./FireAlarmDisplay.vue";
import FireAlarmButtons from "./FireAlarmButtons.vue";
import FireAlarmIndicators from "./FireAlarmIndicators.vue";

export default {
  components: {
    FireAlarmDisplay,
    FireAlarmButtons,
    FireAlarmIndicators,
  },
  data() {
    return {};
  },
  methods: {
    handleButtonClick(buttonId) {
      console.log(`Button ${buttonId} clicked`);
      // 处理按钮点击逻辑
      switch (buttonId) {
        case "reset":
          this.handleReset();
          break;
        case "ok":
          this.handleOk();
          break;
        // 其他按钮处理...
      }
    },
    handleIndicatorChange(indicator) {
      // 处理指示灯状态变化
      this.indicators[indicator.id] = indicator.active;
    },
    handleReset() {
      // 复位逻辑
      this.displayText = "系统复位中...";
      setTimeout(() => {
        this.displayText = "系统正常";
        this.resetIndicators();
      }, 1000);
    },
    resetIndicators() {
      // 重置所有指示灯状态
      Object.keys(this.indicators).forEach((key) => {
        this.indicators[key].active = false;
      });
      this.indicators.mainPower.active = true;
    },
    handleOk() {
      // OK按钮逻辑
      this.displayText = "操作确认";
    },
  },
};
</script>

<style lang="less" scoped>
.container1 {
  // width: 800px;
  // height: 780px;
  height: 100%;
  text-align: center;
  background-color: #4d4946;
  border-radius: 15px;
  padding: 20px;
  // margin-top: 80px;
  color: white;
  .content {
    display: flex;
    justify-content: space-between;
    height: calc(100% - 100px);
    .left {
      flex: 1;
      height: 100%;
      margin-right: 10px;
    }

    .right {
      flex: 1;
      // padding-left: 10px;
      display: flex;
      justify-content: space-between;
      border-radius: 6px;
      background-color: #4d4946;
      box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
      .item {
        flex: 1;
      }
    }
  }
  .title-box {
    height: 80px;
    line-height: 80px;
    text-align: center;
    font-size: 1.6rem;
    letter-spacing: 4px;
    color: #fff;
    margin-top: 20px;
    border-radius: 6px;
    background-color: #4d4946;
    border: 1px solid #484441;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
  }
}
</style>